﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.Filters.BloomFilter
{
    /// <summary>
    /// This class represents a string object for a multiple BloomFilter.
    /// </summary>
    [Serializable]
    public class MultipleBloomFilterStringObject : IMultipleBloomFilter
    {
        /// <summary>
        /// A field, which holds the string value of the object.
        /// </summary>
        private string value;

        /// <summary>
        /// Initializes a new instance of the <see cref="MultipleBloomFilterStringObject"/> class.
        /// </summary>
        /// <param name="value">The value of the object.</param>
        public MultipleBloomFilterStringObject(string value)
        {
            this.value = value;
        }

        /// <summary>
        /// Gets or sets the value of the object.
        /// </summary>
        /// <value>The value of the object.</value>
        public string Value
        {
            get { return value; }
            set { this.value = value; }
        }

        /// <summary>
        /// Gets the hash codes, which will be used by the BloomFilter.
        /// </summary>
        /// <param name="instanceNumber">The instance number, which describes the index of the algorithm for
        /// generating the hash value.</param>
        /// <returns>
        /// The hash codes, which will be used by the BloomFilter
        /// </returns>
        public UInt64 GetBloomHashCode(int instanceNumber)
        {
            switch (instanceNumber)
            {
                case 0:
                    return HashFactory.BPHash(value);

                case 1:
                    return HashFactory.SDBMHash(value);

                case 2:
                    return HashFactory.SAXHash(value);

                case 3:
                    return HashFactory.OneAtATimeHash(value);
            }

            throw new ArgumentException("This object supports only 4 hash instances.");
        }
    }
}